// Product 接口
interface Product {
    void operation();
}

// ConcreteProductA 和 ConcreteProductB 类
class ConcreteProductA implements Product {
    public void operation() {
        System.out.println("ConcreteProductA operation");
    }
}

class ConcreteProductB implements Product {
    public void operation() {
        System.out.println("ConcreteProductB operation");
    }
}

// Factory 接口
interface Factory {
    Product factoryMethod();
}

// ConcreteFactory1 和 ConcreteFactory2 类
class ConcreteFactory1 implements Factory {
    public Product factoryMethod() {
        return new ConcreteProductA();
    }
}

class ConcreteFactory2 implements Factory {
    public Product factoryMethod() {
        return new ConcreteProductB();
    }
}

// 测试类
public class FactoryMethodTest {
    public static void main(String[] args) {
        Factory factory1 = new ConcreteFactory1();
        Product product1 = factory1.factoryMethod();
        product1.operation();

        Factory factory2 = new ConcreteFactory2();
        Product product2 = factory2.factoryMethod();
        product2.operation();
    }
}